Headlines
Loading...
C Program to compute the series

C Program to compute the series

C Program to compute the series

#include<stdio .h="">
#include<conio .h="">
int fact(int no)
{
int i,f=1;
for(i=1;i&lt;=no;i++)
{
f=f*i;
}
return f;
}
void main()
{
int j,n;
float s=0,f;
clrscr();
printf("\nEnter the value of n: ");
scanf("%d",&amp;n);
for(j=1;j&lt;=n;j++)
{
f=fact(j);
s=s+1/f;
}
printf("Value of s is %0.3f",s);
getch();
}

************OUTPUT**************

Enter the value of n: 5
Value of s is 1.717</conio></stdio>
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***